<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use \yii\helpers\Url;

?>

<div class="easyui-panel" title="New Topic" style="width:100%;padding:30px 60px;">
    <form id="ff" class="easyui-form" method="post" action="<?=Url::toRoute('article/add');?>" data-options="novalidate:true">
        <input type="hidden" name="_csrf" value="<?=Yii::$app->request->getCsrfToken()?>" />
        <div style="margin-bottom:20px">
            <input class="easyui-textbox" name="title" style="width:100%" data-options="label:'标题:',required:true">
        </div>
        <div style="margin-bottom:20px">
            <input class="easyui-textbox" name="subhead" style="width:100%" data-options="label:'子标题:',required:true">
        </div>
        <div style="margin-bottom:20px">
            <input class="easyui-textbox" name="content" style="width:100%;height:60px" data-options="label:'简介:',multiline:true">
        </div>
        <div style="margin-bottom:20px">
            <select class="easyui-combobox" name="language" label="Language" style="width:100%"><option value="ar">Arabic</option><option value="bg">Bulgarian</option><option value="ca">Catalan</option><option value="zh-cht">Chinese Traditional</option><option value="cs">Czech</option><option value="da">Danish</option><option value="nl">Dutch</option><option value="en" selected="selected">English</option><option value="et">Estonian</option><option value="fi">Finnish</option><option value="fr">French</option><option value="de">German</option><option value="el">Greek</option><option value="ht">Haitian Creole</option><option value="he">Hebrew</option><option value="hi">Hindi</option><option value="mww">Hmong Daw</option><option value="hu">Hungarian</option><option value="id">Indonesian</option><option value="it">Italian</option><option value="ja">Japanese</option><option value="ko">Korean</option><option value="lv">Latvian</option><option value="lt">Lithuanian</option><option value="no">Norwegian</option><option value="fa">Persian</option><option value="pl">Polish</option><option value="pt">Portuguese</option><option value="ro">Romanian</option><option value="ru">Russian</option><option value="sk">Slovak</option><option value="sl">Slovenian</option><option value="es">Spanish</option><option value="sv">Swedish</option><option value="th">Thai</option><option value="tr">Turkish</option><option value="uk">Ukrainian</option><option value="vi">Vietnamese</option></select>
        </div>
    </form>
    <div style="text-align:center;padding:5px 0">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">Submit</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">Clear</a>
    </div>
</div>
<script>
    function submitForm(){
        $('#ff').form('submit',{
            onSubmit:function(){
                return $(this).form('enableValidation').form('validate');
            },
            success: function(data){
                console.log(data);
                var data = eval('(' + data + ')');  // change the JSON string to javascript object
                if (data.code==1){
                    $.messager.show({
                        title:'My Title',
                        msg:data.msg,
                        timeout:5000
                    });
                }else if(data.code==2){
                    $.messager.alert('My Title',data.msg,'info');
                }
            }
        });
    }
    function clearForm(){
        $('#ff').form('clear');
    }
</script>






